package controlador;

import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.Executions;
import org.zkoss.zk.ui.Session;
import org.zkoss.zk.ui.Sessions;
import org.zkoss.zk.ui.select.SelectorComposer;
import org.zkoss.zk.ui.select.annotation.Wire;
import org.zkoss.zul.Menuitem;
import org.zkoss.zul.Window;
import org.zkoss.zk.ui.event.MouseEvent;
import org.zkoss.zk.ui.select.annotation.Listen;


public class ControladorPerfilUsuario extends SelectorComposer<Component>{
private static final long serialVersionUID = 1L;
	
	@Wire
	private Menuitem MnuInicio;
	@Wire
	private Menuitem MnuCambiar;
	@Wire
	private Menuitem MnuCerrar;

	public ControladorPerfilUsuario(){
		super();
	}
	
	@Listen("onClick = menuitem#MnuInicio")
	public void mostrarMenuInicio(MouseEvent event){
		cerrar();
		Executions.sendRedirect("WebPortal.zul");
		}
	
	@Listen("onClick = menuitem#MnuCambiar")
	public void mostrarMenuCambiar(MouseEvent event){
		cerrar();
		Executions.sendRedirect("RecuperarContrasenna.zul");
	}
		public void cerrar(){
		Window win = (Window)this.getSelf() ;
	    win.detach() ;
	}
	
	@Listen("onClick = menuitem#MnuCerrar")
	public void cerrarSesion(MouseEvent event){
		cerrar();
		Session miSesion = Sessions.getCurrent();
		miSesion.invalidate();
		Executions.sendRedirect("WebPortal.zul");
	}
}

